package com.week2.day03;

public class Dog implements Comparable<Dog>,Swimable{
    private String name;
    private int age;
    public Dog() {
    }

    public Dog(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return this.name+","+this.age;
    }

    @Override
    public int compareTo(Dog o) {
        int age = this.age;
        int targetAge = o.age;
        return age-targetAge;
    }

    @Override
    public void swim() {
        System.out.println(name+"正在游泳");
    }
}
